﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class Admin_Login : System.Web.UI.Page
{
    DataClasses1DataContext ctx = new DataClasses1DataContext();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Btn_Login_Click(object sender, EventArgs e)
    {
        var a = txt_account.Text;
        var b = txt_password.Text;

        Login(a, b);
    }
    private void Login(string name, string pwd)
    {
        try
        {
            var a = ctx.T_User.Single(p => p.UserName.Equals(name) && p.Password.Equals(pwd) && p.Role.Equals(99));
            Session["Admin"] = name;
            Response.Redirect("main.aspx");
        }
        catch
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('登录失败！')", true);
        }
    }
}